// Copyright DustedPixels.com 2008. All rights reserved.

package com.dustedpixels.jasmin.unit.compiler;

import java.util.HashSet;
import java.util.Set;

/**
 * @author micapolos@gmail.com (Michal Pociecha-Los)
 */
public final class Unit {
  public String qualifiedName;
  public String packageName;
  public String name;
  public String[] imports = new String[0];  
  public Arguments constructorArgs;
  public FieldLine[] fieldLines = new FieldLine[0];
  public ConstructorLine[] constructorLines = null;
  public UpdateEndPointsLine[] updateEndPointsLines = new UpdateEndPointsLine[0];
  
  public Set<String> unitFieldNames;
  
  public Unit(String packageName, String name) {
    this.packageName = packageName;
    this.name = name;
    this.qualifiedName = packageName + "." + name;
  }

  public Unit(String qualifiedName) {
    this.qualifiedName = qualifiedName;
    
    int lastDotIndex = qualifiedName.lastIndexOf('.');
    this.packageName = qualifiedName.substring(0, lastDotIndex);
    this.name = qualifiedName.substring(lastDotIndex + 1);
  }
}
